package com.base.common.converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

import org.operamasks.faces.annotation.Convert;
import org.operamasks.faces.annotation.DefineConverter;
import org.operamasks.faces.annotation.Format;

/**
 * 转换是否的类
 * 
 * 
 */
@DefineConverter(id = "yesNoFormatter")
public class YesNoConverter implements Converter {
	@Format
	public String format(Object value) {
		boolean temp = (Boolean) value;
		if (temp)
			return "是";
		if (!temp)
			return "否";
		return "";
	}

	@Convert
	public Object convert(String value) {
		return null;
	}

	@Override
	public Object getAsObject(FacesContext context, UIComponent component,
			String value) {
		return null;
	}

	@Override
	public String getAsString(FacesContext context, UIComponent component,
			Object value) {
		boolean temp = (Boolean) value;
		if (temp)
			return "是";
		if (!temp)
			return "否";
		return "";
	}

}
